import React,{Component} from 'react';
import {Route, Switch} from 'react-router-dom';
import {ScrollHiddenPage} from '../../utils/config'
import Main from '../../containers/main';
// import Assortment from '../../containers/assortment';
import {ScrollTop} from '../../utils/DomApi'
import connectRoute from '../../utils/connectRoute';
import asyncComponent from '../../utils/AsyncComponent';



const HMain = connectRoute(Main);
const AsyncAssortment = connectRoute(asyncComponent(() => import("../../containers/assortment")));
const ItemClass = connectRoute(asyncComponent(() => import("../../containers/itemClass")));
const Brand           = connectRoute(asyncComponent(() => import("../../containers/brand")));
const FullView        = connectRoute(asyncComponent(() => import("../../containers/fullView")));
const ContactUs       = connectRoute(asyncComponent(() => import("../../containers/contactUs")));
const BrandClass      = connectRoute(asyncComponent(() => import("../../containers/brandClass")));
const Body=document.getElementsByTagName('body');

export default class extends Component {
    componentDidUpdate(){
        const RegHiddens=new RegExp(ScrollHiddenPage);

        let isOverHidden=this.props.location.pathname.match(RegHiddens);
        console.log(this.props.location.pathname)
        if(isOverHidden){
            Body[0].style.overflow='hidden'
        }else{
            Body[0].style.overflow='auto'
        }
    }
    render(){
        const {match}=this.props;


        return (<div>
                    <Switch>
                        <Route exact path={match.url} component={HMain}/>
                        <Route path={match.url+'/main'} component={HMain}/>
                        <Route path={match.url+'/brand/:id'} component={Brand}/>
                        <Route path={match.url+'/brandClass/:id'} component={BrandClass}/>
                        <Route path={match.url+'/assortment'} component={AsyncAssortment}/>
                        <Route path={match.url+'/itemClass/:id'} component={ItemClass}/>
                        <Route path={match.url+'/fullView'} component={FullView}/>
                        <Route path={match.url+'/contactUs'} component={ContactUs}/>
                    </Switch>
               </div>)
    }
}